import turtle as t
import easygui as g


def smart_scale(s, w, h):
    d = 0
    if s == '男':
        d = w - (h - 100)
        if d > 3:
            return '你需要减肥了'
        elif d < -3:
            return '你太瘦了'
        else:
            return '你的体重非常标准'
    else:
        d = w - (h - 110)
        if d > 3:
            return '你需要减肥了'
        elif d < -3:
            return '你太瘦了'
        else:
            return '你的体重非常标准'

#闰年计算器


def leap_year(y):
    if y % 400 == 0:
        return str(y)+'是闰年'
    elif y % 4 == 0 and y % 100 != 0:
        return str(y)+'是闰年'
    else:
        return str(y)+'不是闰年'

#水仙花数


def flower():
    a = []
    for i in range(100, 1000):
        if (i//1 % 10)**3+(i//10 % 10)**3+(i//100 % 10)**3 == i:
            a.append(i)
    return '水仙花数有：'+str(a)

#画若干个五角星


def star(n, c, s, b):
    t.speed(0)
    t.pencolor(c)
    t.pensize(s)
    t.bgcolor(b)
    for i in range(n):
        for j in range(5):
            t.forward(200)
            t.right(144)
        t.right(360/n)
    t.hideturtle()
    t.done()
# print(tool.smart_scale('男', 60, 165))

# print(tool.leap_year(2020))

# print(tool.flower())

# print(tool.star(60, 'pink', 5, 'black'))
def app():
    a = g.buttonbox(msg='', title='codemao', choices=('⚖', '⏳', '❀', '★'))
    if a == '⚖':
        sc()
    elif a == '⏳':
        ly()
    elif a == '❀':
        fl()
    elif a == '★':
        st()


#智能体重秤
def sc():
    msg = "请输入你的性别、体重、身高"
    title = "智能体重秤"
    fieldName = ["性别", "体重","身高"]
    fieldValues = g.multenterbox(msg, title, fieldName)
    #如何在输入框取值
    if fieldValues == None:
        app()
    s = fieldValues[0]
    w = float(fieldValues[1])
    h = float(fieldValues[2])
    #智能体重秤的结果
    r = smart_scale(s, w, h)
    t = g.msgbox(msg=r, title="codemao")
    if t == "OK":
        sc()

#闰年计算器
def ly():
    msg = "请输入年份"
    title = "闰年计算器"
    fieldName = ["年份"]
    fieldValues = g.multenterbox(msg, title, fieldName)
    #如何在输入框取值
    if fieldValues == None:
        app()
    y = int(fieldValues[0])
    l = tool.leap_year(y)
    t = g.msgbox(msg=l, title="codemao")
    if t == "OK":
        ly()

#水仙花数
def fl():
    f = flower()
    t = g.msgbox(msg=f, title="codemao")
    if t == "OK":
        app()

#画五角星
def st():
    msg = "颜色请使用英文"
    title = "画五角星"
    fieldName = ["画几个", "画笔颜色", "画笔大小","背景颜色"]
    fieldValues = g.multenterbox(msg, title, fieldName)
    #如何在输入框取值
    if fieldValues == None:
        app()
    n = int(fieldValues[0])
    c = fieldValues[1]
    s = fieldValues[2]
    b = fieldValues[3]
    star(n, c, s, b)

#主程序
app()


